<%@ page import="bid.dao.UserDao" %>
<%@ page import="bid.dao.impl.UserDaoImpl" %>
<%@ page import="bid.entity.User" %><%--
  Created by IntelliJ IDEA.
  User: oldliu
  Date: 2023-10-24
  Time: 15:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>管理员新增</title>
</head>
<body>
<%
    long id = Long.parseLong(request.getParameter("id"));
    UserDao userDao = new UserDaoImpl();
    User user = userDao.get(id);
    //out.print(user);
%>
<h2>添加一个管理员</h2>
<form action="doUpdateUser.jsp" method="post">
    <p>
        编号:<input type="text" value="<%=user.getId()%>" name="id" readonly/>
    </p>
    <p>
        姓名:<input type="text" value="<%=user.getName()%>" required name="name" pattern="\W{2,30}"/>
    </p>
    <p>
        密码:<input type="password" value="<%=user.getPassword()%>" required name="password" pattern="\w{2,30}"/>
    </p>
    <p>
        登录名:<input type="text" value="<%=user.getUsername()%>" required name="username" pattern="\w{2,30}"/>
    </p>
    <p>
        手机号:<input type="tel" value="<%=user.getTelephone()%>" required name="telephone" pattern="1\d{10}"/>
    </p>
    <p>
        入职时间:<input type="date" value="<%=user.getEnterdate()%>" name="enterdate"/>
    </p>
    <p>
        单位:<input type="text" value="<%=user.getUnit()%>" name="unit"/>
    </p>
    <p>
        身份证号:<input type="text" value="<%=user.getIdcard()%>" required name="idcard"/>
    </p>
    <p>
        角色：
        <select name="role" id="role">
            <option value="1">省局</option>
            <option value="2">市局</option>
            <option value="3">县局</option>
        </select>
    </p>
    <p>
        <input type="submit" value="保存"/>
        <input type="reset" value="重填"/>

    </p>

</form>
<script>
    var d=document.getElementById("role");
    for(var i=0;i<d.options.length;i++){
        if(d.options[i].value=='<%=user.getRoleid()%>'){
            d.selectedIndex=i;
            break;
        }
    }
</script>
</body>
</html>
